<template>
  <div>
    <input ref="autoFocus" v-model="inputValue" placeholder="请输入内容">
  </div>

</template>


<script setup>
import { onMounted, ref } from 'vue'
// 通过ref获取到dom元素
const autoFocus = ref(null)

// 当页面所有元素挂载好后,让输入框自动获取光标
onMounted(() => {
  if(autoFocus.value) {
    autoFocus.value.focus()
  }
})

</script>

<style scoped>
.box {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  padding: 20px;
}

.my-button {
  display: inline-block;
  text-align: center;
  vertical-align: middle;
  padding: 15px 32px;
  text-decoration: none;
  font-size: 16px;
  font-weight: 400;
}
</style>
